package com.um.pasantiaum;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

import com.parse.ParseUser;
import com.um.pasantiaum.cliente.MainActivity;
import com.um.pasantiaum.empresa.MainActivityEmpresa;
import com.um.pasantiaum.truck.TruckLocationActivity;

public class DispatchActivity extends Activity {

	public DispatchActivity() {
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		// Check if there is current user info
		if (ParseUser.getCurrentUser() != null) {
			// Start an intent for the logged in activity
			// startActivity(new Intent(null));
			if (!(boolean) ParseUser.getCurrentUser().getBoolean("userType"))
				startActivity(new Intent(this, MainActivity.class));
			else {
				if (!(boolean) ParseUser.getCurrentUser().getBoolean("isTruck"))
					startActivity(new Intent(this, MainActivityEmpresa.class));
				else
					startActivity(new Intent(this, TruckLocationActivity.class));
			}

		} else {
			// Start and intent for the logged out activity
			startActivity(new Intent(this, LoginActivity.class));
		}
	}
}
